<template>
  <div>
    <div class="done-wrap">
      <imgUpload v-model="imgList"></imgUpload>
      <div class="btn-wrap">
        <Button size="large" type="danger" @click="handleClick">维修完成</Button>
      </div>
    </div>
  </div>
</template>

<script>
  import imgUpload from './components/imgUpload'
  import {Button, MessageBox} from 'mint-ui'
  export default {
    name: "done",
    components: {
      imgUpload,
      Button
    },
    data () {
      return {
        imgList: []
      }
    },
    methods: {
      handleClick() {
        if(this.imgList.length == 0) {
          MessageBox.alert('维修员必须上传维修凭证才能修改完成状态');
        } else {
          let params = {
            done_imglist: this.imgList,
            id: this.$route.query.id,
            status: 3
          }
          this.$axios.patch('/admin/repairRecord/', params).then(res => {
            if(res.code == 200){
              MessageBox.alert('该记录已被标记为维修完成');
              this.$router.push({
                name: 'all'
              })
            }
          })
        }
      }
    }
  }
</script>

<style scoped>
  .done-wrap, .btn-wrap {
    padding: 10px;
  }

</style>
